#include <string.h>
#include <iostream>
#include <fstream>
#include <sstream>
#include <map>
using namespace std;

class String{
public:
    void read(const string & filename){
        ifstream ifs(filename);
        if(!ifs.good()){
            cout << "eorror" << endl;
            return;
        }

        string line;
        while(getline(ifs,line)){
            istringstream iss(line);
            string word;
            while(iss >> word){
                ++_wordfrequency[word];
            }
        }
        ifs.close();
    }
    void store(const string & filename){
        ofstream ofs(filename);
        for(auto & ele:_wordfrequency){
            ofs << ele.first << ":" << ele.second << endl;
        }
        ofs.close();
    }


private:
    map<string,int> _wordfrequency;
};

void test(){
    String str;
    str.read("The_Holy_Bible.txt");
    str.store("the_bible.txt");

}

int main()
{
    test();
    return 0;
}

